//
//  CarTableViewCell.m
//  19--Homework 汽车之家
//
//  Created by 冀永金 on 16/8/9.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "CarTableViewCell.h"
#import "HomeOfCar.h"
#import "UIImageView+WebCache.h"
@interface CarTableViewCell ()

@end

@implementation CarTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return  self;
}
- (void)createViews {
    self.carLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_carLabel];
   // _carLabel.backgroundColor = [UIColor yellowColor];
    self.carImage = [[UIImageView alloc]init];
    [self.contentView addSubview:_carImage];
    //_carImage.backgroundColor = [UIColor redColor];
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.carImage.frame = CGRectMake(0, 0, self.contentView.bounds.size.height * 4 /3, self.contentView.bounds.size.height);
    self.carLabel.frame = CGRectMake(self.contentView.bounds.size.height * 4 /3 + 5, 10, 250, 60);
}
-(void)setCar:(HomeOfCar *)car {
    _car = car;
    self.carLabel.text = car.name;
    NSURL *url = [NSURL URLWithString:car.imgurl];
    [self.carImage sd_setImageWithURL:url];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
